<template>
  <el-tree :data="data" :props="defaultProps" @node-click="NodeClick" node-key="catId"
           :expand-on-click-node="false">
  </el-tree>
</template>

<script>
export default {
  components: {},
  data () {
    return {
      data: [],
      draggable: false,
      dialogVisible: false,
      defaultProps: {
        children: 'children',
        label: 'name'
      }
    }
  },
  computed: {},
  watch: {},
  methods: {
    // 获取菜单
    getMenus () {
      this.$http({
        url: this.$http.adornUrl('/product/category/list/tree'),
        method: 'get'
      }).then(({data}) => {
        console.log(data.data)
        this.data = data.data
      })
    },
    NodeClick (data, node, component) {
      console.log('当前节点被点击', data, node, component)
      this.$emit('tree-node-click', data, node, component)
    }
  },
  beforeCreate () {
  },

  created () {
    this.getMenus()
  },

  beforeMount () {

  },

  mounted () {

  },

  beforeUpdate () {

  },

  updated () {

  },

  beforeDestroy () {

  },
  destroyed () {

  },

  activated () {

  }
}
</script>

<style scoped>

</style>
